package com.echat.elocation.util;

import android.annotation.SuppressLint;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DataFormatUtil {

    @SuppressLint("SimpleDateFormat")
    public static String getGpsLocalTime(long gpsTime) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(gpsTime);
        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
        return df.format(calendar.getTime());
    }

    public static String getDirection(float bearing){
        String direction;
        if((bearing >= 0 && bearing <= 22) || (bearing <= 360 && bearing >= 338)){
            direction = "正北";
        } else if (bearing > 22 && bearing < 76) {
            direction = "东北";
        } else if(bearing >= 76 && bearing <= 112){
            direction = "正东";
        } else if(bearing > 112 && bearing < 158){
            direction = "东南";
        } else if(bearing >= 158 && bearing <= 202){
            direction = "正南";
        } else if(bearing > 202 && bearing < 248){
            direction = "西南";
        } else if(bearing >= 248 && bearing <= 292){
            direction = "正西";
        } else if(bearing > 292 && bearing < 338){
            direction = "西北";
        } else {
            direction = "方向错误";
        }
        return direction;
    }
}
